package com.travelranking.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.travelranking.converter.TravelConverter;
import com.travelranking.dao.RankingDAO;
import com.travelranking.pojo.Travel;

@Transactional
public class RankingServiceImpl implements RankingService {
	
	private RankingDAO dao;
	
	//TODO matar e usar na action, talvez criando constantes
	public List<Integer> listRankValues(){
		List<Integer> list = new ArrayList<Integer> ();
		for (int i = 0; i<=10; i++){
			list.add(i);
		}
		return list;
	}

	@Override
	public void add(Travel t){
		dao.saveTravel(TravelConverter.toEntity(t));
	}
	
	@Override
	public List<Travel> list(){
		//TODO: inserir validações e trataemntos de exceptions
		return TravelConverter.toPojoList(dao.listTravel());
	}

	
	public RankingDAO getDao() {
		return dao;
	}
	public void setDao(RankingDAO dao) {
		this.dao = dao;
	}
}
